<template>

  <div>
    <el-card class="box-card"  >
      <div>
        <div class="map">
          <div style="float:left;display: inline-block" >
            <div id="myChart" style="width: 300px; height: 230px;" ></div>
            <div id="myChart1" style="width: 300px; height: 230px;"></div>
            <div id="myChart2" style="width: 300px; height: 230px; " ></div>
          </div>

          <div style="float:right;display: inline-block">
            <div id="myChart3" style="width: 300px; height: 230px;" ></div>
            <div id="myChart4" style="width: 300px; height: 230px;"></div>
            <div id="myChart5" style="width: 300px; height: 230px; " ></div>
          </div>

          <div class="map1"></div>
          <div class="map2"></div>
          <div class="map3"></div>


        </div>
      </div>


    </el-card>

  </div>
</template>

<link rel="stylesheet" href="src/assets/index.css" />

<script>

import * as echarts from 'echarts';
import request from "@/utils/request";
export default {

  data() {
    return {
      date:[],
      total:0,
      profit:0,
    };
  },
  mounted() {


     this.findEcharts();
     this.findEcharts1();
     this.findEcharts2();
     this.findEcharts3();
     this.findEcharts4();
     this.findEcharts5();

  },
  methods: {


    findEcharts(){
      request.get("/inventory/yuce").then( res => {
        this.drawLine(res.data.data)
      })
    },
    drawLine(data){


      var chartDom = document.getElementById('myChart');
      var myChart = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度西瓜销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        dataZoom: {
          type: 'inside',  //放大缩小x轴数值
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度西瓜销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };


      option && myChart.setOption(option);

    },

    findEcharts1(){
      request.get("/inventory/yuce1").then( res => {
        this.drawLine1(res.data.data)
      })
    },
    drawLine1(data){

      var chartDom = document.getElementById('myChart1');
      var myChart1 = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度草莓销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度草莓销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };

      option && myChart1.setOption(option);

    },

    findEcharts2(){
      request.get("/inventory/yuce2").then( res => {
        this.drawLine2(res.data.data)
      })
    },
    drawLine2(data){

      var chartDom = document.getElementById('myChart2');
      var myChart2 = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度香蕉销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度香蕉销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };


      option && myChart2.setOption(option);

    },

    findEcharts3(){
      request.get("/inventory/yuce3").then( res => {
        this.drawLine3(res.data.data)
      })
    },
    drawLine3(data){

      var chartDom = document.getElementById('myChart3');
      var myChart3 = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度苹果销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度苹果销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };


      option && myChart3.setOption(option);

    },

    findEcharts4(){
      request.get("/inventory/yuce4").then( res => {
        this.drawLine4(res.data.data)
      })
    },
    drawLine4(data){

      var chartDom = document.getElementById('myChart4');
      var myChart4 = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度2024年新木桌子销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度2024年新木桌子销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };


      option && myChart4.setOption(option);

    },

    findEcharts5(){
      request.get("/inventory/yuce5").then( res => {
        this.drawLine5(res.data.data)
      })
    },
    drawLine5(data){

      var chartDom = document.getElementById('myChart5');
      var myChart5 = echarts.init(chartDom);
      var option;

      let x = [];
      let y = [];

      for (let i = 0; i < data.length; i++) {
        //x[i]获取json的姓名，y[i]获取json的值
        x[i] = data[i].name;
        y[i] = data[i].value;

      }

      option = {
        tooltip: {
          trigger: 'axis'
        },
        legend: {
          data: ['本年度2024年新木椅子销量']
        },
        grid: {
          left: '3%',
          right: '4%',
          bottom: '3%',
          containLabel: true
        },
        toolbox: {
          feature: {
            saveAsImage: {}
          }
        },
        xAxis: {
          type: 'category',
          boundaryGap: false,
          data: x
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            name: '本年度2024年新木椅子销量',
            type: 'line',
            stack: 'Total',
            data: y,
            smooth: true
          },
        ]
      };


      option && myChart5.setOption(option);

    },


  }
}
</script>


<style>
.no {
  background-color: #fc3e1c;
  padding: 0.1875rem;
}
.no .no-hd {
  position: relative;
  border: 1px solid rgba(25, 186, 139, 0.17);
}
.no .no-hd::before {
  content: "";
  position: absolute;
  width: 30px;
  height: 10px;
  border-top: 2px solid #02a6b5;
  border-left: 2px solid #02a6b5;
  top: 0;
  left: 0;
}
.no .no-hd::after {
  content: "";
  position: absolute;
  width: 30px;
  height: 10px;
  border-bottom: 2px solid #02a6b5;
  border-right: 2px solid #02a6b5;
  right: 0;
  bottom: 0;
}
.no .no-hd ul {
  display: flex;
}
.no .no-hd ul li {
  position: relative;
  flex: 1;
  text-align: center;
  height: 1rem;
  line-height: 1rem;
  font-size: 1.85rem;
  color: #ffeb7b;
  padding: 0.05rem 0;
  font-family: electronicFont;
  font-weight: bold;
}
.no .no-hd ul li:first-child::after {
  content: "";
  position: absolute;
  height: 80%;
  width: 1.5px;
  background-color: #153cd3;
  right: 0;
  top: 25%;
}
.no .no-bd ul {
  display: flex;
}
.no .no-bd ul li {
  flex: 1;
  height: 0.5rem;
  line-height: 0.5rem;
  text-align: center;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.7);
  padding-top: 0.125rem;
}


.map {
  position: relative;
  height: 20rem;
}
.map .chart {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  height: 10.125rem;
  width: 100%;
}
.map .map1,
.map .map2,
.map .map3 {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 18rem;
  height: 18rem;
  background: url(../assets/map.png) no-repeat;
  background-size: 100% 100%;
  opacity: 0.3;
}
.map .map2 {
  width: 22.0375rem;
  height: 22.0375rem;
  background-image: url(../assets/lbx.png);
  opacity: 0.6;
  animation: rotate 15s linear infinite;
  z-index: 2;
}
.map .map3 {
  width: 20.075rem;
  height: 20.075rem;
  background-image: url(../assets/jt.png);
  animation: rotate1 10s linear infinite;
}

@keyframes rotate {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}
@keyframes rotate1 {
  from {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(-360deg);
  }
}
@media screen and (max-width: 1024px) {
  html {
    font-size: 42px !important;
  }
}
@media screen and (min-width: 1920px) {
  html {
    font-size: 80px !important;
  }
}
</style>
